﻿<?xml version="1.0" encoding="UTF-8"?>
<AppletManifest xmlns="http://openiz.org/mobile/applet">
	<info>
		<name>Patient Registration</name>
		<version>1.0.0.0</version>
		<author>OpenIZ.org Community</author>
		<icon>@drawable/register_patient</icon>
		<id>org.openiz.applets.core.patient.register</id>
		<groupName>Patient Management</groupName>
	</info>
	<tile size="sm">
		<text>Register Patient</text>
		<icon>@drawable/register_patient</icon>
	</tile>
	<asset name="index" mimeType="text/html">
		<contentXml>
			<body ng-controller="RegisterPatientController" xmlns="http://www.w3.org/1999/xhtml">
				<form novalidate="novalidate" name="registrationForm">
					<div class="container">
						<div class="row">
							<div class="col-md-12">
								<div class="panel panel-default">
									<div class="panel-heading">
										<h2 class="panel-title">Demographic Information</h2>
									</div>
									<div class="panel-body">
										<div class="container-fluid">
											<div class="row">
												<div class="pull-left" style="width:20%; border: dashed 2px #555; ">
													<img alt="user picture" id="patient-picture" src="app://openiz.org/drawable/drk_patient" style="width:100%" />
													<div class="input-group">
														<a ng-click="setPicture(patient)" class="input-group-addon">
															<span class="glyphicon glyphicon-camera">
															</span>
														</a>
														<a ng-click="removePicture(patient)" class="input-group-addon">
															<span class="glyphicon glyphicon-trash">
															</span>
														</a>
													</div>
												</div>
												<div class="pull-right" style="width:79%">
													<div class="input-group" id="given0">
														<span class="input-group-addon" id="givenNameLabel0">Given:</span>
														<input ng-model="patient.given" type="text" class="form-control" placeholder="Given Name" name="givenName0" id="givenName0" aria-describedby="givenNameLabel0" />
														<span class="input-group-addon">
															<a ng-click="addGiven(patient)">
																<span class="glyphicon glyphicon-plus">
																</span>
															</a>
														</span>
														<span class="input-group-addon">
															<a ng-click="removeGiven(this)">
																<span class="glyphicon glyphicon-minus">
																</span>
															</a>
														</span>
													</div>
													<div class="input-group" id="family0">
														<span class="input-group-addon" id="familyNameLabel0">Family:</span>
														<input ng-model="patient.family" type="text" class="form-control" placeholder="Family Name" name="familyName0" id="familyName0" aria-describedby="familyNameLabel0" />
														<span class="input-group-addon">
															<a ng-click="addFamily(patient)">
																<span class="glyphicon glyphicon-plus">
																</span>
															</a>
														</span>
														<span class="input-group-addon">
															<a ng-click="removeFamily(this)">
																<span class="glyphicon glyphicon-minus">
																</span>
															</a>
														</span>
													</div>
													<div class="input-group" id="dob">
														<span class="input-group-addon" id="dobLabel">Date of Birth:</span>
														<input ng-model="patient.dob" type="date" data-max-date="0" class="form-control" name="dob" id="dob" aria-describedby="dobLabel" />
														<span class="input-group-addon">
															Accuracy:
														</span>
														<select ng-model="patient.dob_accuracy" class="form-control" name="dobAccuracy" id="dobAccuracy">
															<option value="d" selected="selected">Day</option>
															<option value="m">Month</option>
															<option value="y">Year</option>
														</select>
													</div>
													<div class="input-group" id="dob">
														<span class="input-group-addon" id="genderLabel">Gender:</span>
														<select ng-model="patient.gender" ng-options="item.Key as item.Mnemonic for item in administrativeGenderConcepts" class="form-control" name="gender" id="gender" aria-describedBy="genderLabel">
															<option value="">Gender</option>
														</select>
													</div>
												</div>
											</div>
										</div>
									</div>
									<div class="panel-footer">
										Potential Duplicates
									</div>
									<table class="table">
										<thead>
											<tr>
												<th>Name (s)</th>
												<th>Birthdate</th>
												<th>Gender</th>
												<th>City/Village(s)</th>
												<th>
												</th>
											</tr>
										</thead>
										<tbody>
											<tr>
												<td>Smith, Jennifer Ashley</td>
												<td>10-NOV-2015</td>
												<td>Female</td>
												<td>Village 2</td>
												<td>
													<a href="app://openiz.org/applet/org.openiz.applets.core.patient.search/view?pid=1023" class="btn btn-default">
														View <span class="glyphicon glyphicon-eye-open"></span></a>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<div class="panel panel-default">
									<div class="panel-heading">
										<h2 class="panel-title">Identification</h2>
									</div>
									<div class="panel-body">
										<div class="input-group" id="patientId0">
											<span class="input-group-addon" id="identifierLabel0">Id:</span>
											<input ng-model="patient.id_value" type="text" class="form-control" placeholder="0303030303" name="identifierValue0" id="identifierValue0" aria-describedby="identifierLabel0" />
											<span class="input-group-addon">
												<a ng-click="scanBarcode(this)">
													<span class="glyphicon glyphicon-barcode">
													</span> Scan
				                              		</a>
											</span>
											<select ng-model="patient.id_type" class="form-control" name="identifierType0" id="identifierType0">
												<option value="ycn" selected="selected">Yellow Card ID</option>
												<option value="hin">Health Insurance #</option>
												<option value="other">Other</option>
											</select>
											<span class="input-group-addon">
												<a ng-click="addId(patient)">
													<span class="glyphicon glyphicon-plus">
													</span>
												</a>
											</span>
											<span class="input-group-addon">
												<a ng-click="removeId(this)">
													<span class="glyphicon glyphicon-minus">
													</span>
												</a>
											</span>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<div class="panel panel-default">
									<div class="panel-heading">
										<h2 class="panel-title">Domicile</h2>
									</div>
									<div class="panel-body">
										<div class="input-group">
											<span class="input-group-addon" id="homeCityLabel">City/Town(s):</span>
											<select ng-model="patient.city" class="form-control" name="homeCity" id="homeCity" aria-describedBy="homeCityLabel" multiple="multiple" data-openiz-tag="select2">
												<option value="ycn">Village 1</option>
												<option value="hin">City 1</option>
												<option value="other">City 2</option>
											</select>
										</div>
										<div class="input-group">
											<span class="input-group-addon" id="birthPlaceLabel">Birth Place:</span>
											<select ng-model="patient.birthPlace" class="form-control" name="birthPlace" id="birthPlace" aria-describedBy="birthPlaceLabel" data-openiz-tag="select2">
												<option value="ycn">Hospital 1</option>
												<option value="hin">Hospital 2</option>
												<option value="other">Clinic 1</option>
											</select>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<div class="panel panel-default">
									<div class="panel-heading">
										<h2 class="panel-title">
											<a href="#contactInformation" data-toggle="collapse">Contact Information</a>
										</h2>
									</div>
									<div class="panel-collapse collapse" id="contactInformation">
										<div class="panel-body">
											<div class="input-group" id="patientTel0">
												<span class="input-group-addon" id="telephoneLabel0">Tel:</span>
												<input ng-model="patient.telephone" type="text" class="form-control" placeholder="+255-302-302-2034" name="telephone0" id="telephone0" aria-describedby="telephoneLabel0" />
												<span class="input-group-addon">
													<span class="glyphicon glyphicon-earphone">
													</span>
												</span>
												<select ng-model="patient.telephone_type" class="form-control" name="telephoneType0" id="telephoneType0">
													<option value="home" selected="selected">Home</option>
													<option value="mobile">Mobile</option>
													<option value="work">Work</option>
												</select>
												<span class="input-group-addon">
													<a ng-click="addTel(patient)">
														<span class="glyphicon glyphicon-plus">
														</span>
													</a>
												</span>
												<span class="input-group-addon">
													<a ng-click="removeTel(this)">
														<span class="glyphicon glyphicon-minus">
														</span>
													</a>
												</span>
											</div>
											<div class="input-group" id="patientEmail0">
												<span class="input-group-addon" id="emailLabel0">E-Mail:</span>
												<input ng-model="patient.email" type="text" class="form-control" placeholder="someone@somedomain.com" name="email0" id="email0" aria-describedby="emailLabel0" />
												<span class="input-group-addon">
													@
											</span>
												<select ng-model="patient.email_type" class="form-control" name="emailType0" id="emailType0">
													<option value="home" selected="selected">Home</option>
													<option value="mobile">Mobile</option>
													<option value="work">Work</option>
												</select>
												<span class="input-group-addon">
													<a ng-click="addEmail(patient)">
														<span class="glyphicon glyphicon-plus">
														</span>
													</a>
												</span>
												<span class="input-group-addon">
													<a ng-click="removeEmail(this)">
														<span class="glyphicon glyphicon-minus">
														</span>
													</a>
												</span>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="pull-right btn-group">
		                        <button class="btn btn-lg btn-danger" ng-click="close()">
		                          <span class="glyphicon glyphicon-remove">
		                          </span> 
		                          Cancel
		                        </button>
		                        <button class="btn btn-lg btn-primary" ng-click="saveClose(patient)">
		                          Save &amp; Close
		                          <span class="glyphicon glyphicon-floppy">
		                          </span> 
		                        </button>
		                        <button class="btn btn-lg btn-success" ng-click="saveCheckin(patient)">
		                          Save &amp; Check-in <span class="glyphicon glyphicon-floppy-saved"></span>
		                        </button>
		                      </div>
						</div>
					</div>
				</form>
				<!-- OpenIZ:Scripts -->
			</body>
		</contentXml>
	</asset>
	<asset name="index-controller" mimeType="text/javascript">
		<contentText><![CDATA[
        // angular stuff
		var registerApp = angular.module('index', []);

		registerApp.controller('RegisterPatientController', ['$scope', function ($scope)
		{	
			$scope.administrativeGenderConcepts = OpenIZ.Concept.getConceptSet('AdministrativeGender');
			$scope.master = {};

			$scope.close = function() {
				if(confirm(OpenIZ.App.getString("applet_confirm_close")))
					OpenIZ.App.back();
			};
			$scope.saveCheckin = function(patient) {
				OpenIZ.App.navigateApplet("org.openiz.applets.core.patient.checkin", patient);
			};
			$scope.saveClose = function(patient) {
				OpenIZ.App.close();
			};
	    }]);
      ]]></contentText>
	</asset>
</AppletManifest>